home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
bsrc_250.zip
/
MDM_PROC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-15
|
24KB
|
648 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software, Co. */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / Freely Available<tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
/* */
/* */
/* This module was written by Vince Perriello */
/* */
/* */
/* BinkleyTerm Modem Handler Module */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.250. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT BIT BUCKET */
/* SOFTWARE CO. AT ONE OF THE ADDRESSES LISTED BELOW. IN NO EVENT */
/* SHOULD YOU PROCEED TO USE THIS FILE WITHOUT HAVING ACCEPTED THE */
/* TERMS OF THE BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER */
/* AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO. */
/* */
/* */
/* You can contact Bit Bucket Software Co. at any one of the following */
/* addresses: */
/* */
/* Bit Bucket Software Co. FidoNet 1:104/501, 1:343/491 */
/* P.O. Box 460398 AlterNet 7:491/0 */
/* Aurora, CO 80046 BBS-Net 86:2030/1 */
/* Internet f491.n343.z1.fidonet.org */
/* */
/* Please feel free to contact us at any time to share your comments about */
/* our software and/or licensing policies. */
/* */
/*--------------------------------------------------------------------------*/
/* Include this file before any other includes or defines! */
#include "includes.h"
int dial_modem (char *);
void phone_translate (char *, char *);
char *get_response (long);
int parse_response (char *);
void empty_delay (void);
#define FAILURE 0
#define IGNORE 1
#define CONNECTED 2
#define RINGING 3
#define INCOMING 4
struct resp_str
{
char *resp;
unsigned disp;
};
static struct resp_str mdm_resps[] = {
{"RINGING", 1},
{"RING RESPONSE", 1},
{"RING", 3},
{"CONNECT", 2},
{"RRING", 1},
{"BUSY", 0},
{"VOICE", 0},
{"ERROR", 0},
{"OK", 0},
{"NO CARRIER", 0},
/* "NO DIAL TONE" or "NO DIALTONE" */ {"NO DIAL", 4},
{"DIALING", 1},
{"NO ANSWER", 0},
{"DIAL TONE", 1},
{NULL, 0}
};
static char *response_string = " ";
void do_dial_strings ()
{
MDM_TRNS *m;
predial = normprefix;
postdial = normsuffix;
m = mm_head;
while (m != NULL)
{
if (m->mdm & newnodedes.ModemType)
{
predial = m->pre;
postdial = m->suf;
return;
}
m = m->next;
}
}
void try_2_connect (char *phnum)
{
long t1;
int j, k;
for (j = 0; (j < poll_tries && !KEYPRESS ()); j++) /* do polltries or till keypress */
{
CLEAR_INBOUND ();
k = dial_modem (phnum);
if ((un_attended || doing_poll) && fullscreen)
{
++hist.calls_made;
(void) sprintf (junk, "%-4d", hist.calls_made);
sb_move (history_hWnd, HIST_ATT_ROW, HIST_COL);
sb_puts (history_Out, junk);
}
if ((k > 0) || KEYPRESS ())
break;
t1 = timerset (200);
mdm_hangup ();
while (!timeup (t1) && !KEYPRESS ())
time_release (); /* pause for 2 seconds */
}
if (KEYPRESS ()) /* If user's been busy */
{
(void) FOSSIL_CHAR (); /* Eat the character */
if (!CARRIER) /* Abort if no carrier */
{
status_line (MSG_TXT(M_CONNECT_ABORTED));
mdm_hangup ();
}
}
predial = normprefix;
postdial = normsuffix;
}
int try_1_connect (char *phnum)
{
int k;
if ((k = dial_modem (phnum)) <= 0)
{
if (k != -2) /* NO DIAL TONE needs express service */
mdm_hangup ();
}
if ((un_attended || doing_poll) && fullscreen)
{
++hist.calls_made;
(void) sprintf (junk, "%-4d", hist.calls_made);
sb_move (history_hWnd, HIST_ATT_ROW, HIST_COL);
sb_puts (history_Out, junk);
}
predial = normprefix;
postdial = normsuffix;
return (k);
}
void phone_translate (char *number, char *translated)
{
PN_TRNS *p;
(void) strcpy (translated, number);
for (p = pn_head; p != NULL; p = p->next)
{
if (strncmp (p->num, number, (unsigned int) (p->len)) == 0)
{
(void) sprintf (translated, "%s%s%s", p->pre, &(number[p->len]), p->suf);
break;
}
}
}
int dial_modem (char *number)
{
int resp;
long t;
char translated[50];
janus_OK = 0;
ARQ_lock = 0;
phone_translate (number, translated);
if (translated[0] == '\"') /* If it's a script */
{
resp = do_script (translated); /* then do it that way */
if (fullscreen) /* & clean up the bottom line*/
bottom_line ();
return (resp);
}
status_line (MSG_TXT(M_DIALING_NUMBER), translated);
if (un_attended && fullscreen)
{
do_ready (MSG_TXT(M_READY_DIALING));
}
/* First of all, if we have something, don't hang up on the guy! */
if (!no_collide && CHAR_AVAIL ())
return (-1);
if (dial_setup != NULL)
{
mdm_cmd_string (dial_setup, 1);
}
else
{
LOWER_DTR (); /* drop DTR to reset modem */